package main

import "fmt"

func main() {

	// 测试AddTwoSlices
	var slice1 = []int{1, 2, 3}
	var slice2 = []int{4, 5, 6}
	slice3 := AddTwoSlices(slice1, slice2)
	fmt.Printf("slice3: %v \n", slice3)
	fmt.Printf("slice1: %v \n", slice1)

	// 测试RemoveFromSlice
	var slice4 = []int{1, 2, 3, 4}
	slice5 := RemoveFromSlice(slice4, 2)
	fmt.Printf("slice5: %v \n", slice5)
}

func AddTwoSlices(slice1 []int, slice2 []int) []int {
	for _, element := range slice2 {
		slice1 = append(slice1, element)
	}
	return slice1
}

func RemoveFromSlice(slice []int, element int) []int {
	for index, ele := range slice {
		if ele == element {
			before := slice[:index]
			after := slice[index+1:]
			slice = AddTwoSlices(before, after)
		}
	}
	return slice
}
